package com.wzy.netty.core.buf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

/**
 * 描述
 * 创建人    Wzy
 * 创建时间: 2020-05-22  1:06
 */
public class NettyByteBuf01 {
    public static void main(String[] args) {

        /*
         *在netty的buffer中不需要反转 flip
         * 底层维护了raederindex 和 witerIndex
         *0-readerindex 已经读取的区区
         * readerindex-writerIndex 可读的区域
         * writerindex-capacity,可写的区域
         *
         */
        ByteBuf buffer = Unpooled.buffer();
        for (int i = 0; i < 10; i++) {
            buffer.writeByte(i);
        }
        System.out.println("capacity" + buffer.capacity());

        for (int i = 0; i < 10; i++) {
            buffer.readByte();
        }
    }
}
